package com.itcast.cn.jsp.controller;

import com.itcast.cn.jsp.pojo.Brand;
import com.itcast.cn.jsp.service.BrandService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author hyatt
 */
@WebServlet("/deleteServlet")
public class DeleteBrandServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取参数
        int id = Integer.valueOf(request.getParameter("id")).intValue();

        new BrandService().delete(id);
        // 跳转到查询界面，看是否成功
        request.getRequestDispatcher("/selectAll").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
